home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Complete Internet Archive
/
Complete Internet Archive.iso
/
VRML
/
cp2b2x.exe
/
DATA.Z
/
origami.java
< prev
next >
Wrap
Text File
|
1996-06-21
|
3KB
|
118 lines
/*-----------------------------------------------------------------------------
* Copyright(C) 1995,1996 Sony Corporation
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Sony Corporation;
* the contents of this file is not to be disclosed to third parties, copied
* or duplicated in any form, in whole or in part, without the prior written
* permission of Sony Corporation.
*
* File: origami.java
* Auther: sugino
*----------------------------------------------------------------------------*/
import vrml.*;
public class origami extends Script {
SFInt32 paperChild = (SFInt32) getEventOut("paperChild");
SFBool timerOn = (SFBool) getEventOut("timerOn");
SFRotation birdRotation = (SFRotation) getEventOut("birdRotation");
SFTime bgmStop = (SFTime) getEventOut("bgmStop");
SFTime bgmStart = (SFTime) getEventOut("bgmStart");
SFTime gusyaStop = (SFTime) getEventOut("gusyaStop");
SFTime gusyaStart = (SFTime) getEventOut("gusyaStart");
/* number of child */
int max = 8;
/* current child no */
int current = 0;
int xrollMax = 60;
int xroll = 0;
int yrollMax = 60;
int yroll = 0;
boolean rolling= false;
final int rollingX = 1;
final int rollingY = 2;
int rollmode = rollingX;
float rotation[] = new float[4];
float piV = (float)Math.PI/180.0f ;
float xaRad = (360.0f/(float)xrollMax);
float yaRad = (360.0f/(float)yrollMax);
public void clicked (ConstSFBool press, ConstSFTime t) {
if(press.getValue()) return ;
if(rolling) {
rolling=false;
bgmStop.setValue(t.getValue());
}
else {
rolling=true;
gusyaStart.setValue(t.getValue());
bgmStart.setValue(t.getValue());
}
timerOn.setValue(rolling);
nextChild(t);
}
public void roll(ConstSFTime t, ConstSFTime now){
rotation[0]=rotation[1]=rotation[2]=0.0f;
if(rollmode == rollingX){
if(xroll < xrollMax) {
xroll++;
}
else {
xroll = 0;
rollmode = rollingY;
}
}
else {
if(yroll < yrollMax) {
yroll++;
}
else {
yroll = 0;
nextChild(now);
rollmode = rollingX;
}
}
if(rollmode == rollingX){
rotation[0]=1.0f;
rotation[3]= (piV*(xaRad*(float)xroll)) ;
}
else {
rotation[1]=1.0f;
rotation[3]= (piV*(yaRad*(float)yroll)) ;
}
birdRotation.setValue(rotation);
}
void nextChild(ConstSFTime t){
gusyaStop.setValue(t.getValue()-3);
gusyaStart.setValue(t.getValue());
if(current < max-1) current++ ;
else {
current =0;
rolling = false;
timerOn.setValue(rolling);
bgmStop.setValue(t.getValue());
}
paperChild.setValue(current);
}
}